import { Msbmanage } from 'src/msbmanage/entities/msbmanage.entity';
import { Quote } from 'src/quote/entities/quote.entity';
import { Users } from 'src/users/entities/user.entity';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  ManyToOne,
  JoinColumn,
  OneToMany,
  Index,
} from 'typeorm';

@Entity({ name: 'product_infolist' }) // 指定表名
export class ProductInfo {
  @PrimaryGeneratedColumn({ name: '_Identify' })
  id: number;

  @Column()
  productcode: string;

  @Column()
  productname: string;

  @Column()
  specifications: string;

  @Column()
  component: string;

  @Column()
  weight: number;

  @Column()
  width: number;

  @Column()
  color: string;

  @Index({ unique: true })
  @Column()
  productuniquecode: string;

  @Column()
  category: string;

  @Column({ type: 'int' })
  deleted: boolean;

  @Column()
  useridentify: string; // 修改为 string 类型

  @ManyToOne(() => Users, (user) => user.productinfo)
  @JoinColumn({ name: 'useridentify' }) // 确保外键列名正确
  user: Users;

  @OneToMany(() => Quote, (quotes) => quotes.productinfo)
  quotes: Quote[];

  @OneToMany(() => Msbmanage, (msbmanages) => msbmanages.productinfo)
  msbmanages: Msbmanage[];
}
